package br.requisiteworks.util.web;

import java.text.SimpleDateFormat;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

/**
 * Define os formatos dos objetos recebidos como parametros dos controllers
 * 
 * @author Mikhail Domanoski
 * @version 1, 07/05/2010
 * 
 */
public class ApplicationWebDataBinder implements WebBindingInitializer {

	public void initBinder(WebDataBinder binder, WebRequest request) {
		// Date format
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy",
				request.getLocale());
		dateFormat.setLenient(false);
		CustomDateEditor customDateEditor = new CustomDateEditor(dateFormat,
				true);
		binder.registerCustomEditor(java.util.Date.class, customDateEditor);
	}
}
